<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>佰林の商家登录</title>
    <link rel="stylesheet" href="/css/adminStyle.css">
    <link rel="stylesheet" href="/common/layui/css/layui.css">
</head>
<body style="background-image: url(/images/bg-3.jpg);background-size: 150% " >
    <form  class="box" method="post">
        <h2 style="color:#fff5d4">商家登录</h2>
        <input type="text" id="userLogin" name="" placeholder="用户名">
        <input type="password" id="pwdLogin" name="" placeholder="密码">
        <input type="button" id="loginBtn" name="" value="登录" class="layui-btn layui-btn-radius layui-btn-normal">
    </form>
</body>
<!--<script crossorigin="anonymous" integrity="sha512-WNLxfP/8cVYL9sj8Jnp6et0BkubLP31jhTG9vhL/F5uEZmg5wEzKoXp1kJslzPQWwPT1eyMiSxlKCgzHLOTOTQ==" src="https://lib.baomitu.com/jquery/3.5.1/jquery.js"></script>-->
<script src="https://lib.baomitu.com/jquery/3.5.1/jquery.js"></script>
<script>
    /**
     * 登录
     */
    $('#loginBtn').click(function () {
        var userLogin =  $('#userLogin').val();
        var pwdLogin = $('#pwdLogin').val();
        if(userLogin.trim() && pwdLogin.trim()){
            $.ajax({
                url:'loginAndRegister/admin/login',
                type:'post',
                data:JSON.stringify({
                    username: userLogin,
                    password: pwdLogin,
                }),
                contentType: "application/json;charset=UTF-8",
                success: function(data){
                    if(typeof data === 'object'){
                        localStorage.setItem('adminInfo',JSON.stringify(data))
                        sessionStorage.setItem('adminInfo',JSON.stringify(data))
                        window.location.href='/toAdminIndex';
                    }else if(data === 'stop'){
                        alert('用户已停用，请联系管理员')
                    } else if(data==='unDefind'){
                        alert('账号或密码不正确，请检查后尝试')
                    }else{
                        alert('登录失败')
                    }}
            })
        }else{
            alert('账号密码不能为空')
        }

    })
</script>
</html>